package com.example.clientmiviamoviego4;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Classe che definisce i campi essenziali riferiti ad un generico film.
 * 
 * @author Gang of Four
 * */
public class ParcelableMovie implements Parcelable {

	private String id;
	private String title;
	private String date; // dd/mm/yyyy
	private String thumbnailURL; // 32x32

	public ParcelableMovie() {
		title = "";
		id = "";
		date = "";
		thumbnailURL = "";
	}

	public ParcelableMovie(String id, String title, String date,
			String thumbnailURL) {
		this.id = id;
		this.title = title;
		this.date = date;
		this.thumbnailURL = thumbnailURL;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getThumbnailURL() {
		return thumbnailURL;
	}

	public void setThumbnailURL(String thumbnailURL) {
		this.thumbnailURL = thumbnailURL;
	}

	/**
	 * Metodo che descrive il genere di oggetti contenuti in questa
	 * rappresentazione di Parcelable.
	 * */
	@Override
	public int describeContents() {
		return 0;
	}

	/**
	 * Traduce quest'oggetto in un oggetto Parcel.
	 * */
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(title);
		dest.writeString(id);
		dest.writeString(date);
		dest.writeString(thumbnailURL);
	}

	/**
	 * Genera instanze della classe definita come Parcelable a partire da un
	 * oggetto Parcel.
	 * */
	public static final Parcelable.Creator<ParcelableMovie> CREATOR = new Parcelable.Creator<ParcelableMovie>() {
		public ParcelableMovie createFromParcel(Parcel in) {
			return new ParcelableMovie(in);
		}

		public ParcelableMovie[] newArray(int size) {
			return new ParcelableMovie[size];
		}
	};

	/**
	 * Costruttore che a partire da un Parcel ricostruisce un ParcelableMovie.
	 * */
	private ParcelableMovie(Parcel in) {
		this.title = in.readString();
		this.id = in.readString();
		this.date = in.readString();
		this.thumbnailURL = in.readString();
	}

}
